package com.recharge.controller.jd;

import com.alibaba.fastjson.JSON;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date;

/**
 * Created by qi.cao on 2017/2/8.
 */
public class TrafficBeginFill extends JdProtocol {

    /**
     * 京东订单号
     */
    private String fillOrderNo;

    /**
     * 手机号
     */
    private String fillMobile;

    /**
     * 充值流量
     */
    private String fillAmount;

    /**
     * 流量商品类型，例如：标准包、个性包
     */
    private String fillType;

    /**
     * 清算时间
     */
    private String finTime;

    /**
     * 使用范围
     */
    private String areaUsed;

    /**
     * v代理商充值成功后回调通知地址
     */
    private String notifyUrl;

    /**
     * 运营商
     */
    private String mutCode;

    /**
     * 地区
     */
    private String areaCode;

    /**
     * 代理商对京东提供的价格
     */
    private BigDecimal costPrice;

    public static void main(String[] args) {
        Field[] fields = TrafficBeginFill.class.getDeclaredFields();

        String[] temp = new String[fields.length];
        for (int i=0;i<fields.length;i++){
            temp[i] = fields[i].getName();
        }
        Arrays.sort(temp);
        System.out.println(JSON.toJSONString(temp));


    }

    public String getSignString(){
        String signString = "areaCode"+areaCode+"areaUsed"+areaUsed+"costPrice"+costPrice+"fillAmount"+fillAmount
                +"fillMobile"+fillMobile+"fillOrderNo"+fillOrderNo+"fillType"+fillType+"finTime"+finTime+"mutCode"+mutCode+"notifyUrl"+notifyUrl
                +"timestamp"+getTimestamp()+"version"+getVersion();
        try {
            return URLEncoder.encode(signString.replace(" ",""),"GBK");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        return null;
    }


    public String getFillOrderNo() {
        return fillOrderNo;
    }

    public void setFillOrderNo(String fillOrderNo) {
        this.fillOrderNo = fillOrderNo;
    }

    public String getFillMobile() {
        return fillMobile;
    }

    public void setFillMobile(String fillMobile) {
        this.fillMobile = fillMobile;
    }

    public String getFillAmount() {
        return fillAmount;
    }

    public void setFillAmount(String fillAmount) {
        this.fillAmount = fillAmount;
    }

    public String getFillType() {
        return fillType;
    }

    public void setFillType(String fillType) {
        this.fillType = fillType;
    }

    public String getFinTime() {
        return finTime;
    }

    public void setFinTime(String finTime) {
        this.finTime = finTime;
    }

    public String getAreaUsed() {
        return areaUsed;
    }

    public void setAreaUsed(String areaUsed) {
        this.areaUsed = areaUsed;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getMutCode() {
        return mutCode;
    }

    public void setMutCode(String mutCode) {
        this.mutCode = mutCode;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public BigDecimal getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(BigDecimal costPrice) {
        this.costPrice = costPrice;
    }
}
